//package com.yunhe.option.controller.data;
//
//import com.yunhe.option.domain.data.GeneratePrice;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.PageParam;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.option.service.data.GeneratePriceService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//import java.util.Optional;
//
//@Api(value = "generatePrice", description = "发电电价", tags = {"Date_GeneratePrice"})
//@RestController
//@RequestMapping("/price/generate")
//public class GeneratePriceController {
//    @Autowired
//    private GeneratePriceService generatePriceService;
//
//    @ApiOperation("新增发电电价")
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(@RequestBody GeneratePrice generatePrice)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        GeneratePrice newgp = generatePriceService.create(generatePrice);
//        return new ResponseEntity<>(new ResultObject<>(newgp), HttpStatus.OK);
//    }
//
//    @ApiOperation("根据ID删除发电电价")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "发电电价ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(@PathVariable("id") Long id) {
//        generatePriceService.delete(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    @ApiOperation("更新发电电价（全部字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "发电电价ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(@PathVariable("id") Long id,
//                                            @RequestBody GeneratePrice generatePrice)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        generatePrice.setId(id);
//        GeneratePrice newgp = generatePriceService.update(generatePrice);
//        return new ResponseEntity<>(new ResultObject<>(newgp), HttpStatus.OK);
//    }
//
//    @ApiOperation("更新发电电价(指定字段)")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "发电电价ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "title", value = "标题", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "province", value = "省", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "city", value = "市", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "district", value = "区", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "windPrice", value = "风价", dataType = "double", paramType = "query"),
//            @ApiImplicitParam(name = "pvPrice", value = "光价", dataType = "double", paramType = "query"),
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(@PathVariable("id") Long id,
//                                              @RequestParam("title") Optional<String> title,
//                                              @RequestParam("areaList") Optional<List<Long>> areaList,
//                                              @RequestParam("windPrice") Optional<Double> windPrice,
//                                              @RequestParam("pvPrice") Optional<Double> pvPrice)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        GeneratePrice newGP = generatePriceService.update(id, title.orElse(null),
//                areaList.orElse(null), windPrice.orElse(null), pvPrice.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(newGP), HttpStatus.OK);
//    }
//
////    @ApiOperation("获得全部发电电价")
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path")
////    })
////    @RequestMapping(method = RequestMethod.GET)
////    public ResponseEntity<ResultObject> findAll(@PathVariable("systemId") Long systemId){
////        Iterable<GeneratePrice> results = generatePriceService.findGeneratePrices();
////        return new ResponseEntity<>(new ResultObject(results), HttpStatus.OK);
////    }
//
//    @ApiOperation("根据条件获得发电电价")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "queryStr", value = "查询条件", dataType = "string", paramType = "query")
//    })
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search(@RequestParam("queryStr") Optional<String> queryStr,
//                                               @RequestParam("stationId") Optional<Long> stationId,
//                                               @ModelAttribute PageParam pageParam) {
//        Iterable<GeneratePrice> results = generatePriceService.search(queryStr.orElse(null),
//                stationId.orElse(null), pageParam);
//        return new ResponseEntity<>(new ResultObject(results), HttpStatus.OK);
//    }
//
//    @ApiOperation("根据电价ID获得发电电价")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "发电电价ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(@PathVariable("id") Long id) {
//        GeneratePrice gp = generatePriceService.findById(id).get();
//        return new ResponseEntity<>(new ResultObject<>(gp), HttpStatus.OK);
//    }
//
//
//}
